package cn.touna.jss.common.enums;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

public enum BaiRongResultEnum {

    /************百融返回码*************/
    success("00", "操作成功"),
    programmerError("100001", "程序错误"),
    matchIsEmpty("100002", "匹配结果为空"),
    keyIsInValid("100003", "必选key值缺失或不合法"),
    usernameError("100004", "商户不存在或用户名错误"),
    loginPasswdError("100005", "登陆密码不正确"),
    reqParamFormatError("100006", "请求参数格式错误"),
    tokenPast("100007", "Tokenid过期"),
    apiCodeIsEmpty("100008", "客户端api调用码不能为空"),
    ipError("100009", "IP地址错误"),
    outOfTimce("100010", "超出当天访问次数"),
    acountDisable("100011", "账户停用"),
    reqsetmealIsEmpty("100012", "请求套餐为空"),
    reqParamError("100015", "请求参数其他错误"),
    analysisException("100016", "捕获请求json异常，无法解析的错误"),
    /**** 海纳API **/
    haina_success("600000", "操作成功"),
    hainaParamError("600001", "参数错误"),
    hainaTokenIdError("600002", "tokenid错误"),
    hainaNoMethodAuth("600003", "无该接口查询权限,meal 字段输入有误"),
    hainaMoModuleAuth("600004", "无该模块查询权限,index字段输入有误"),
    hainaFailed("600005", "操作失败,请联系客服"),
    hainaExcess("600006", "接口查询次数已用完,请联系客服");
    /**
     * 枚举值
     */
    private final String value;

    /**
     * 枚举文本
     */
    private final String text;

    BaiRongResultEnum(String value, String text) {
        this.value = value;
        this.text = text;
    }

    /**
     * {@inheritDoc}
     */
    public String value() {
        return value;
    }

    /**
     * 获取枚举对象文本
     *
     * @return String
     */
    public String text() {
        return text;
    }

    /**
     * 根据值获取枚举对象
     *
     * @param value 枚举值
     * @return 对象枚举对象
     */
    public static BaiRongResultEnum getloanStatus(String value) {
        for (BaiRongResultEnum status : values()) {
            if (status.value().equals(value)) {
                return status;
            }
        }
        return null;
    }


    /**
     * 根据code获取值
     *
     * @param code 枚举值
     * @return 对象枚举对象
     */
    public static String getValue(String code) {
        for (BaiRongResultEnum status : values()) {
            if (status.value().equals(code)) {
                return status.text();
            }
        }
        return "";
    }


    /**
     * ENUM 转换成MAP
     */
    private static final Map<String, String> riskStatusMap = new HashMap<String, String>();

    static {
        for (BaiRongResultEnum it : EnumSet.allOf(BaiRongResultEnum.class)) {
            riskStatusMap.put(it.value(), it.text());
        }
    }


    public static void main(String[] args) {
//    	  BaiRongResultEnum getloanStatus = BaiRongResultEnum.getloanStatus("1");
//    	  System.out.println(getloanStatus.value());
//    	  System.out.println(getloanStatus.text());
//        getloanStatus("0");
//        Iterator<String> iterator = riskStatusMap.keySet().iterator();
//        while (iterator.hasNext()){
//            String key = iterator.next();
//            System.out.print("key:"+ key);
//            System.out.println(" value:"+riskStatusMap.get(key));
//        }
//         String value = getValue("1");
        System.out.println(" value:" + BaiRongResultEnum.success.text());


    }


}
